<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\select2\Select2;
use \yii\web\JsExpression;

/* @var $this yii\web\View */
/* @var $model backend\models\JjrUserCommission */

$this->title = '添加佣金';
$this->params['breadcrumbs'][] = ['label' => 'Jjr User Commissions', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$searchUrl = \yii\helpers\Url::toRoute("jjr-user-project/search");
?>
<div class="jjr-user-commission-create">

    <h1><?= Html::encode($this->title) ?></h1>

    <div class="jjr-user-commission-form">

        <?php $form = ActiveForm::begin(['id' => 'commission-form',]); ?>

        <?=$form->field($model, 'jjr_user_project_id')->label('项目名称')->widget(Select2::classname(), [
            'initValueText' => $text,
            'options' => ['placeholder' => '请输入结佣项目进行搜索'],
            'pluginOptions' => [
            'ajax' => [
                'url' => $searchUrl,
                'dataType' => 'json',
                'data' => new JsExpression('function(params) { return {q:params.term}; }')
            ],
            'templateResult' => new JsExpression('function(res) { return res.text; }'),
            'templateSelection' => new JsExpression('function (res) { return res.text; }'),
        ]]); ?>
         <?= $form->field($model, 'amount')->textInput(['maxlength' => true]) ?>


        <?= $form->field($model, 'transfer_status')->dropDownList(['1' => '未结佣', '2'=>'已结佣'])->label('结佣状态') ?>

        <div class="form-group">
            <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
        </div>

        <?php ActiveForm::end(); ?>

    </div>

</div>

<!-- 定义数据块 -->
<?php $this->beginBlock('test'); ?>
jQuery(document).ready(function() {
highlight_subnav('jjr-user-commission/index'); //子导航高亮
});
<?php $this->endBlock() ?>
<!-- 将数据块 注入到视图中的某个位置 -->
<?php $this->registerJs($this->blocks['test'], \yii\web\View::POS_END); ?>

